package com.tianya.controller;

import com.tianya.common.Results;
import com.tianya.domain.dto.TeachingProgressRequestDTO;
import com.tianya.domain.entity.Teachingprogress;
import com.tianya.domain.vo.PageResultVO;
import com.tianya.domain.vo.TeachingProgressVO;
import com.tianya.service.TeachingprogressService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

/**
 * @author TianYaGuoKe
 * @date 2025/5/27 9:54
 * @description ProgressController
 */
@Api("进度管理")
@RestController
@RequestMapping("/progress")
public class ProgressController {

    @Resource
    private TeachingprogressService teachingprogressService;

    @ApiOperation("分页查询")
    @GetMapping("/page")
    public Results<PageResultVO<TeachingProgressVO>> listPage(@RequestParam(defaultValue = "1") Integer pageNum,
                                                              @RequestParam(defaultValue = "10") Integer pageSize,
                                                              TeachingProgressRequestDTO teachingProgressRequestDTO) {
        return Results.success(teachingprogressService.listPage(pageNum, pageSize, teachingProgressRequestDTO));
    }

    @ApiOperation("创建进度")
    @PostMapping
    public Results createProgress(@RequestBody Teachingprogress teachingprogress) {
        teachingprogress.setTeacherId(1L);//todo 先设置一个
        teachingprogressService.save(teachingprogress);
        return Results.success();
    }

    @ApiOperation("更新进度")
    @PutMapping
    public Results updateProgress(@RequestBody Teachingprogress teachingprogress) {
        teachingprogressService.updateById(teachingprogress);
        return Results.success();
    }

    @ApiOperation("删除进度")
    @DeleteMapping("/{id}")
    public Results deleteProgress(@PathVariable Long id) {
        teachingprogressService.removeById(id);
        return Results.success();
    }
}
